﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Barbar.Colonization.Core;
using System.Xml.Serialization;

namespace Barbar.Colonization.Model.RuleSets {
  [XmlType(TypeName = "Image", Namespace = Constants.XmlRootNamespace)]
  public class XmlImage : IImage, IRulesetDeserialization {
    private string m_Id;
    private string m_Path;
    private Bitmap m_Bitmap;

    public string Id {
      get { return m_Id; }
      set { m_Id = value; }
    }

    public string Path {
      get { return m_Path; }
      set { m_Path = value; }
    }

    #region IImage Members

    Bitmap IImage.Image {
      get { return m_Bitmap; }
    }

    #endregion

    #region IEntity Members

    string IEntity.Id {
      get { return m_Id; }
    }

    #endregion

    #region IRulesetDeserialization Members

    void IRulesetDeserialization.OnDeserialization(XmlRuleSet ruleSet) {
      m_Bitmap = (Bitmap)Bitmap.FromFile(System.IO.Path.Combine(Utility.ApplicationPath, Path));
    }

    #endregion
  }
}
